<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Controller for managing permissions.
 * @package cms-permissions/conrollers
 * @category Controller
 * 
 * @author Mark Angelo Angulo
 * @copyright (c) 2014
 */
class Permission extends CMS_Controller {

    /**
     *  Constructor method.
     */
    function __construct()
    {
        parent::__construct();

        $this->load->model('permission_model');
        $this->load->model('cms-modules/module_model');
        $this->load->model('cms-roles/role_model');
        
        $this->load->helper('cms');
        $this->load->helper('permission');
        
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<div class="clear-fix"></div><small>', '</small>');
        
        init_permission();
    }

    /**
     * Default method called when nothing is specified.
     * Displays dashboard.
     * @access public
     */
    public function index()
    {
        view_permissions_list();
    }
    
    /**
     * Update Permissions
     * @access public
     */
    public function update_permissions()
    {
        
        if( isset($_POST) && !empty($_POST) )
        {
            $permissions = $this->input->post();
            foreach($permissions as $key => $permission)
            {
                $permission_set = array('group_permissions' => serialize($permission));
                $this->permission_model->update_by_id($key, $permission_set );
            }
            view_permissions_list('Permissions Updated');
        } else
        {
            $this->show_404();
        }
    }
}

/* End of file permission.php */
/* Location: ./application/permissions/cms-permissions/controllers/permission.php */